package com.xja.controller;

import com.xja.pojo.Food;
import com.xja.pojo.Type;
import com.xja.service.FoodService;
import com.xja.service.TypeService;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;

@Controller
@RequestMapping("food")
public class FoodController {
    private Logger logger = LoggerFactory.getLogger(FoodController.class);
    @Reference(url = "dubbo://localhost:20882")
    FoodService foodService;
    @Reference(url = "dubbo://localhost:20883")
    TypeService typeService;

    @RequestMapping("getFoodList")
    public String getFoodList(Model model){
        logger.info("调用获取食物列表方法");
       List<Food> foodList = foodService.getFoodList();
        List<Type> typeList = typeService.getTypeList();
        model.addAttribute("foodList",foodList);
        model.addAttribute("typeList",typeList);
       return "/admin/food_list.html";

    }

    @RequestMapping("test")
    public String test(){
        return "login";
    }

}
